<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="shortcut icon" href="../../../favicon.ico" type="image/x-icon">
	<title>event_handler</title>
</head>
<body>
  <div id="test"></div>

  <script type="text/javascript" src="../../../js/react.development.js" ></script>
  <script type="text/javascript" src="../../../js/react-dom.development.js"></script>
  <script type="text/javascript" src="../../../js/babel.min.js"></script>
  <script type="text/javascript" src="../../../js/prop-types.js"></script>

  <script type="text/babel">
    class Demo extends React.Component {
      myRef = React.createRef()

      showData = ()=>{
        const {current} = this.myRef;
        alert("current: "+current.value);
      }

      showData2 = (event)=>{
        alert("event.target: "+event.target.value)
      }

      render(){
        return (<div>
          <input ref={this.myRef} type="text" placehold="点击按钮提示数据" />
          <button onClick={this.showData}>点击我提示左侧的数据</button>
          <input onBlur={this.showData2} type="text" placehold="失去焦点提示数据" />
          </div>)
      }
    }

    ReactDOM.render(<Demo />, document.getElementById('test'));
  </script>
</body>